home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_HDF.idb / usr / freeware / include / hdf / hbitio.h.z / hbitio.h
Encoding:
C/C++ Source or Header  |  1999-01-26  |  3.3 KB  |  86 lines

  1.  
  2. /****************************************************************************
  3.  * NCSA HDF                                                                 *
  4.  * Software Development Group                                               *
  5.  * National Center for Supercomputing Applications                          *
  6.  * University of Illinois at Urbana-Champaign                               *
  7.  * 605 E. Springfield, Champaign IL 61820                                   *
  8.  *                                                                          *
  9.  * For conditions of distribution and use, see the accompanying             *
  10.  * hdf/COPYING file.                                                        *
  11.  *                                                                          *
  12.  ****************************************************************************/
  13.  
  14. /* $Id: hbitio.h,v 1.14 1996/10/28 22:48:26 koziol Exp $ */
  15.  
  16. /*
  17.    **  hbitio.h
  18.    **
  19.    **  Data structures and macros for bitfile access to HDF data objects.
  20.    **  These are mainly used for compression I/O and N-bit data objects.
  21.  */
  22.  
  23. #ifndef __HBITIO_H
  24. #define __HBITIO_H
  25.  
  26. /* Define the number of elements in the buffered array */
  27. #define BITBUF_SIZE 4096
  28. /* Macro to define the number of bits cached in the 'bits' variable */
  29. #define BITNUM      (sizeof(uint8)*8)
  30. /* Macro to define the number of bits able to be read/written at a time */
  31. #define DATANUM     (sizeof(uint32)*8)
  32.  
  33. typedef struct bitrec_t
  34.   {
  35.       int32       acc_id;       /* Access ID for H layer I/O routines */
  36.       int32       bit_id;       /* Bitfile ID for internal use */
  37.   /* Note that since HDF has signed 32bit offset limit we need to change this to signed
  38.      since the get passed to Hxxx calls which take signed 32bit arguments */
  39.       int32      block_offset, /* offset of the current buffered block in the dataset */
  40.                  max_offset,   /* offset of the last byte written to the dataset */
  41.                  byte_offset;  /* offset of the current byte in the dataset */
  42.  
  43.       intn       count,        /* bit count to next boundary */
  44.                  buf_read;     /* number of bytes read into buffer (necessary for random I/O) */
  45.       uint8       access;       /* What the access on this file is ('r', 'w', etc..) */
  46.       uint8       mode;         /* how are we interacting with the data now ('r', 'w', etc) */
  47.       uint8       bits;         /* extra bit buffer, 0..BITNUM-1 bits */
  48.       uint8      *bytep;        /* current position in buffer */
  49.       uint8      *bytez;        /* end of buffer to compare */
  50.       uint8      *bytea;        /* byte buffer */
  51.   }
  52. bitrec_t;
  53.  
  54. #ifndef BITMASTER
  55. extern
  56. #endif
  57. const uint8 maskc[9]
  58. #ifdef BITMASTER
  59. =
  60. {0, 1, 3, 7, 15, 31, 63, 127, 255}
  61. #endif
  62.            ;
  63.  
  64. #ifndef BITMASTER
  65. extern
  66. #endif
  67. const uint32 maskl[33]
  68. #ifdef BITMASTER
  69. =
  70. {0x00000000,
  71.  0x00000001, 0x00000003, 0x00000007, 0x0000000f,
  72.  0x0000001f, 0x0000003f, 0x0000007f, 0x000000ff,
  73.  0x000001ff, 0x000003ff, 0x000007ff, 0x00000fff,
  74.  0x00001fff, 0x00003fff, 0x00007fff, 0x0000ffff,
  75.  0x0001ffff, 0x0003ffff, 0x0007ffff, 0x000fffff,
  76.  0x001fffff, 0x003fffff, 0x007fffff, 0x00ffffff,
  77.  0x01ffffff, 0x03ffffff, 0x07ffffff, 0x0fffffff,
  78.  0x1fffffff, 0x3fffffff, 0x7fffffff, 0xffffffffUL}
  79. #endif
  80.            ;
  81.  
  82. /* Function-like Macros */
  83. #define Hputbit(bitid,bit) ((Hbitwrite(bitid,1,(uint32)bit)==FAIL) ? FAIL : SUCCEED)
  84.  
  85. #endif /* __HBITIO_H */
  86.